package com.cssl.controller;

import com.cssl.domain.dto.DtsCartDto;
import com.cssl.openFeign.DtsCartOpenFeignClient;
import com.cssl.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/cart")
@Api(value = "购物车接口",tags = "购物车相关操作")
public class DtsCartController {
    @Resource
    private DtsCartOpenFeignClient client;

    @PostMapping("/getCartGoodsCount")
    @ApiOperation(value = "获得用户购物车商品数量")
    public Result getCartGoodsCount(){
        return client.getCartGoodsCount();
    }
    @PostMapping("/addCartGoods")
    @ApiOperation(value = "新增购物车商品",notes = "cartDto")
    public Result addCartGoods(@RequestBody DtsCartDto cartDto){
        return client.addCartGoods(cartDto);
    }
    @PostMapping("/getCartInfoByUid")
    @ApiOperation(value = "获得用户购物车",notes = "无需参数")
    public Result getCartInfoByUid(){
        return client.getCartInfoByUid();
    }
    @PostMapping("/checkedGoods")
    @ApiOperation(value = "更改购物车中的商品是否选中",notes = "productIds,isChecked")
    public Result checkedGoods(@RequestBody Map map){
        return client.checkedGoods(map);
    }

    @PostMapping("/changeNumber")
    @ApiOperation(value = "更改购物车商品数量",notes = "number,cartId")
    public Result changeNumber(@RequestBody Map map){
        return client.changeNumber(map);
    }

    @PostMapping("/minusCarGoods")
    @ApiOperation(value = "删除购物车商品",notes = "id集合")
    public Result minusCarGoods(@RequestBody Map<String, List<Integer>> map){
        return client.minusCarGoods(map);
    }
}
